home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 001-025 / scopedisk4 / macfont / extract.h < prev    next >
C/C++ Source or Header  |  1995-03-18  |  1KB  |  41 lines

  1. /* These macros are for extracting an integer of a certain type
  2.  * from the midst of an arbitrary chunk of memory.
  3.  *
  4.  * Due to the offset based Macintosh resource system you have to
  5.  * do this a lot...
  6.  *
  7.  */
  8.  
  9. #define UC(p) ((unsigned char *)(p))
  10.  
  11. #ifdef MPU68000
  12.  
  13. /* this will work on any machine with 68000 style endain ordering */
  14. /* p should be a pointer to char */
  15.  
  16. #define X_ULONG(p) (*((ULONG *)(p)))
  17. #define X_UWORD(p) (*((UWORD *)(p)))
  18. #define X_UBYTE(p) (*((UBYTE *)(p)))
  19.  
  20. #define X_LONG(p) (*((LONG *)(p)))
  21. #define X_WORD(p) (*((WORD *)(p)))
  22. #define X_BYTE(p) (*((BYTE *)(p)))
  23.  
  24. #else
  25.  
  26. /* this will work on any machine but it's not as fast as the above */
  27.  
  28. #define X_ULONG(p) (ULONG)(UC(p)[0]<<24|UC(p)[1]<<16|UC(p)[2]<<8|UC(p)[3])
  29. #define X_UWORD(p) (UWORD)(UC(p)[0]<<8|UC(p)[1])
  30. #define X_UBYTE(p) (UBYTE)(UC(p)[0])
  31. #define X_LONG(p)  (LONG)((UC(p)[0]<<24|UC(p)[1]<<16|UC(p)[2]<<8|UC(p)[3])
  32. #define X_WORD(p)  (WORD)(UC(p)[0]<<8|UC(p)[1])
  33. #define X_BYTE(p)  (BYTE)(UC(p)[0])
  34.  
  35. #endif
  36.  
  37. /* artificial types... have to fake them */
  38.  
  39. #define X_UTRIP(p) (ULONG)(UC(p)[0]<<16|UC(p)[1]<<8|UC(p)[2])
  40. #define X_TRIP(p)  (LONG)(UC(p)[0]<<16|UC(p)[1]<<8|UC(p)[2])
  41.